from modelscope.models import Model
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

# 定义模型名称
model_name = '/root/paraformer'

# 加载模型
model = Model.from_pretrained(model_name, disable_update=True,update_model=False,revision="v2.0.4")

# 创建语音转文字处理管道
pipe = pipeline(task=Tasks.auto_speech_recognition,disable_update=True,update_model=False,model=model)

# 输入测试语音
file = 'demo.wav'

# 执行语音转文件操作
result = pipe(file)

# 打印输出结果
print("result :", result)
print("text   :", result[0].get('text'))
